<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <a href="http://127.0.0.1:8080/user/1/admin">点击</a>
    <button id="btn">确定</button>
    <script>
      //   btn.onclick = function () {
      //     console.log("ok");
      //   };
      var btn = document.querySelector("#btn");
      btn.onclick = function () {
        var id = 1;
        var str = "http://127.0.0.1:8080/user/" + id;
        document.querySelector("a").href = str;
      };
    </script>
  </body>
</html>
